--蓄栌断彻
local xuluduanche = fk.CreateSkill {
    name = "mcdh_xuluduanche"
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

xuluduanche:addEffect(fk.TargetSpecified,{
    can_trigger = function(self, event, target, player, data)
        return target == player and player:hasSkill(self) and data:isOnlyTarget(data.to)
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local judge = {
            who = player,
            reason = self.name,
            pattern = ".|.|.|.|.|" .. data.card:getTypeString(),
        }
        room:judge(judge)
    end,
})

xuluduanche:addEffect(fk.FinishJudge,{
    can_refresh = function(self, event, target, player, data)
        return  data.reason == self.name and data.who == player
    end,
    on_refresh = function(self, event, target, player, data)
        local room =player.room
        if data.card:matchPattern(data.pattern) then
            local choices = { "xuluduanche1", "xuluduanche2" }
            local choice = room:askForChoice(player, choices, self.name, nil, nil, { "xuluduanche1", "xuluduanche2" })
            if choice == "xuluduanche1" then
                room:moveCards({
                    ids = {data.card.id},
                    to = player,
                    toArea = Card.PlayerHand,
                    moveReason = fk.ReasonPrey,
                    skillName = self.name,
                    moveVisible = true
                })
            elseif choice == "xuluduanche2" then
                local e = room.logic:getCurrentEvent():findParent(GameEvent.UseCard)
                if e then
                    local use = e.data
                    use.disresponsiveList = room.alive_players
                end
            end
        end

    end,
})

Fk:loadTranslationTable {
    ["mcdh_xuluduanche"] = "蓄栌断彻",
    [":mcdh_xuluduanche"] = "当你使用牌指定一名角色为唯一目标后，你可以进行一次判定。若判定结果与此牌类型相同，你选择一项：1.获得此判定牌；2.令此牌不可响应。",
    ["xuluduanche1"] = "1.获得此判定牌",
    ["xuluduanche2"] = "2.令此牌不可响应",
}

return xuluduanche